﻿package  
{
	import adobe.utils.CustomActions;
	import com.cubeia.firebase.io.protocol.CreateTableRequestPacket;
	import com.cubeia.firebase.io.protocol.CreateTableResponsePacket;
	import com.cubeia.firebase.io.protocol.LeaveRequestPacket;
	import com.cubeia.firebase.io.protocol.KickPlayerPacket;
	import com.cubeia.firebase.io.protocol.ServiceTransportPacket;
	import com.cubeia.firebase.util.ParameterUtil;
    import com.cubeia.firebase.io.protocol.Param;
	import flash.sampler.NewObjectSample;
	import flash.text.TextFormat;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat ;
	import flash.net.sendToURL;
	import flash.net.navigateToURL;
	import flash.net.URLRequest ;
	import flash.net.URLVariables ;
	import flash.net.URLRequestMethod ;
	import flash.net.URLRequestHeader ;	
	import flash.sampler.DeleteObjectSample;
	import flash.system.Security;
	import flash.text.TextField;
	import flash.errors.IOError;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.errors.*;
	import gs.*;
	import gs.easing.*;
	import com.greensock.*;
	import com.greensock.easing.*;
	import com.athena.vo.*;
	import com.athena.controller.*;
	import com.athena.process.* ;
	import flash.display.*;
	import flash.utils.*;
	import flash.events.*;
	import fl.containers.ScrollPane; 
	import fl.controls.ScrollPolicy; 
	import fl.controls.DataGrid; 
	import fl.data.DataProvider;
	import flash.net.URLRequest;
	import flash.net.URLLoader;
	import com.adobe.serialization.json.JSON;
	import flash.text.TextFieldAutoSize;
	import flash.external.ExternalInterface;
	import fl.transitions.Tween;
	import fl.transitions.easing.*;
	import fl.transitions.TweenEvent;
	import flash.system.LoaderContext;
	import flash.system.ApplicationDomain;
	import com.junkbyte.console.Cc;
	
	public class Cocaro {
		// Initialization:
		public static var GAME_ID : int = 8000;
		public static var PARAM_CREATE_TABLE:Array = new Array();
		public static var tableID:int;
		public static var oldaddressLobby:String = "";
		public static var newaddressLobby:String = "";
		
		public static var isView : Boolean = false ; //La nguoi xem hay choi		
		
		public static var CountSelection : int = 0 ;		
		public static var TimerConection:Timer = new Timer(1000);//Dieu khien thoi gian he thong	
		
		public static var strSendOld : String  = "";
		public static var isSend : Boolean  = false;
		public static var isKickRoom : Boolean = false ;		
		public static var DisplayIconTimer:Timer = new Timer(1000);//Dieu khien dong ho hien thi icon		
		public static var comdTimer:Timer = new Timer(1000) ; //Dieu khien thuc hien cac lenh
		public static var comdATTimer:Timer = new Timer(1000) ; //Dieu khien thuc hien cac lenh
		
		public static var htmlGameChat : String = "" ;
		public static var htmlWorldChat : String = "" ;
		public static var htmlPrivateChat : String = "" ;
		public static var htmlAllChat : String = "" ;
		
		public static var xosoTimer:Timer = new Timer(1000) ; //Dieu khien thuc hien cac lenh
				
		public static var isBegin : Boolean = true;
		public static var mainStage_mc : MovieClip;
		
		public static var mainSocket : CustomSocket;
		public static var LastMarkTable : Number = 0 ;
		
		public static var playerCards : Array = new Array() ;
		public static var movieHistoryTF : Array = new Array() ;
		
		public static var arrLevelInfor : Array = new Array() ;
		
		//public static var vipSilver : int = 4 ;		
		//public static var vip : int = 8 ;	
		public static var vipSilver : Number = 1000000 ;		
		public static var vip : Number = 5000000 ;
		/************************/
		public static var msgSound : Sound ;
		public static var kickSound : Sound ;
		public static var finishedSound : Sound ;
		
		public static var preURLSound : String = "./flash/sound/" ;
		
		public static var ArrNameEmotions : Array = ["Emotion7.swf","Emotion8.swf","Emotion9.swf","Emotion10.swf","Emotion11.swf","Emotion12.swf","Emotion13.swf","Emotion14.swf","Emotion15.swf"] ;		
		public static var ArrEmotion : Array ; //Bang danh sach Emotion		
		
		public static var ArrCard_Fix : Array ;
		
		public static var currPlayer:ObjectPlayer = new ObjectPlayer();
		public static var currLevel:ObjectLevelRoom ;
		public static var currRoom:ObjectRoom ;
		public static var levelID;
		public static var isSound : Boolean = true ;
		
		public static var AGTransfer: Number = 0 ;
		
		public static var mcMove : MovieClip ;
		public static var xMove : Number ;
		public static var yMove : Number ;
		
		public static var kickProfile : Boolean = false ;
		
		public static var markInit : Number = 0 ;
		public static var PlayMoney : int = 0 ;
		public static var tabDefault : int = 1 ;
		
		public static var strTemp : String = "" ;
		
		public static var roomID : int ;
		public static var port:String;
		public static var host:String;//"athenavn.no-ip.org" ;//"localhost";
		public static var user:UserInfo;		
		
		public static var arrQC : Array ; 
		public static var ArrBackGround : Array ; 
		public static var preURLFeed : String = "http://bacay.athena.vn/bacay/feed.aspx" ;
		public static var preURLEmotion : String = "./flash/Emotion/" ;
		public static var preURLXML : String = "./flash/" ;
		
		public static var urlTopCT_Trongngay : String = "http://services.athena.vn/ServiceGame/CTTrongNgay.aspx?gid=8000" ;
		public static var urlTopDG : String = "http://services.athena.vn/ServiceGame/DaigiaNgay.aspx" ;
		public static var urlTopCT_Homtruoc : String = "http://services.athena.vn/ServiceGame/CThomqua.aspx?gid=8000" ;
		public static var urlTopCT_Tuan : String = "http://services.athena.vn/ServiceGame/CTTuan.aspx?gid=8000" ;
		public static var urlTopCT_Thang : String = "http://services.athena.vn/ServiceGame/CTThang.aspx?gid=8000" ;
		public static var urlTyle : String = "http://services.athena.vn/ServiceGame/Tyle.aspx" ;
		//public static var ArrNameBG : Array = ["BG.jpg", "Khung_BB.png", "Khung_CT.png", "Khung_Tin.swf", "Logo_3cay.png", "Khung_Top.png", "BGListTable.png", "BG_Ban.jpg"] ;
		//public static var ArrBG : Array ; //Danh sach cac image Load duoc		
		
		//public static var ArrPopupName : Array = ["pp_Taoban.png", "pp_Vaoban.png", "pp_Khoebanbe.png", "pp_Ketqua.png"] ;
		//public static var ArrPopupBG : Array ;
		public static var tf:TextField = new TextField();
		public static var numberWarning : int = 0 ;
		public static var myXML:XML = null;
		public static var ObjProfile : Object = null;
		
		public static var imageLoaderMain:Loader;
		public static var imageMain:URLRequest ;
		
		
		public static var InitMoney : int = 0 ;
		public static var NonPlayMoney: int = 0;
		public static var strChuong: String = "Chương đã về tay ta....!";
		public static var formatTextMain : TextFormat ;
		
		public static var formatAvatar_Name : TextFormat ;
		public static var formatAvatar_Mark : TextFormat ;
		public static var formatAvatar_MarkLQ : TextFormat ;
		public static var formatAvatar_MarkInGame : TextFormat ;		
		
		public static var christmas_Loader : Loader ;
		//Load tu ngoai
		public static var Popup_Daugia : Class ;
		public static var Auction_Item : Class ;
		public static var AuctionWin_Item : Class ;
		public static var Auction_ItemShow : Class ;
		//Xoso
		public static var Popup_Xoso : Class ;
		public static var Lottery_Item : Class ;
		public static var Lottery_ItemWin : Class ;
		//Bai may man
		public static var Popup_Baimayman : Class ;
		public static var LuckyCard_Item : Class ;
		public static var LuckyCard : Class ;
		public static var Lucky_Mau : Class ;
		public static var Lucky_Doi : Class ;
		public static var Lucky_Thu : Class ;
		public static var Lucky_Xam : Class ;
		public static var Lucky_Sanh : Class ;
		public static var Lucky_Thung : Class ;
		public static var Lucky_Culu : Class ;
		public static var Lucky_Tuquy : Class ;
		public static var Lucky_Thungphasanh : Class ;
		//Other
		public static var Popup_ConvertGold : Class ;
		public static var Popup_SpecialAlert : Class ;
		
		public function Cocaro(main:MovieClip)
		{ 
			Cc.startOnStage(main, "");
			mainStage_mc = main;
			mainStage_mc.bgMain_mc.visible = false;
			mainStage_mc.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove) ;
			//Khoi tao 
			formatTextMain = new TextFormat() ;				
			formatTextMain.font = "Tahoma" ;
			formatTextMain.bold = true ;
			formatTextMain.size = 14 ;	

			formatAvatar_Name = new TextFormat() ;				
			formatAvatar_Name.font = "Tahoma" ;
			formatAvatar_Name.bold = true ;
			formatAvatar_Name.size = 13 ;			
			formatAvatar_Name.color = 0xE5DFE9 ;
			
			formatAvatar_Mark = new TextFormat() ;				
			formatAvatar_Mark.font = "Tahoma" ;
			formatAvatar_Mark.bold = true ;
			formatAvatar_Mark.size = 12 ;			
			formatAvatar_Mark.color = 0xE5DFE9 ;
			
			formatAvatar_MarkLQ = new TextFormat() ;				
			formatAvatar_MarkLQ.font = "Tahoma" ;
			formatAvatar_MarkLQ.bold = true ;
			formatAvatar_MarkLQ.size = 12 ;			
			formatAvatar_MarkLQ.color = 0x00FF00 ;
			
			formatAvatar_MarkInGame = new TextFormat() ;				
			formatAvatar_MarkInGame.font = "Tahoma" ;
			formatAvatar_MarkInGame.bold = true ;
			formatAvatar_MarkInGame.size = 12 ;			
			formatAvatar_MarkInGame.color = 0xFFFFFF ;
			
			arrLevelInfor = new Array() ;
			ArrEmotion = new Array() ;
			arrQC = new Array() ;
			isSound = true ;
			numberWarning = 0 ;
			//tf.autoSize = TextFieldAutoSize.LEFT;
			//tf.border = true;	
			//tf.textColor = 0xFFFFFF;
			//mainStage_mc.addChild(tf);	
			LoadAuction(preURLXML + "Auction.swf") ;
			var objret:Array = ExternalInterface.call("getInfoUser") as Array;
			user = new UserInfo();
			
			user.SessionId = objret[0];
			user.UserId = objret[1];
			user.Username = objret[2];
			if ((objret[3] == "") || (objret[3] == null))
				user.From = "bacay";
			else
				user.From = objret[3];
			host = objret[4];
			port = objret[5];
			//Khoi tao mang quan bai
			ArrCard_Fix = new Array();
			var m : int = 0 ;
			for (var k:int = 1; k < 5; k++) 
			{
				for (var l:int = 2; l < 11; l++) 
				{
					m++ ;
					var o : Object = new Object() ;
					o.S = k ;
					o.N = l ;
					o.I = m ;
					ArrCard_Fix.push(o) ;
				}
			}			
			//tf.appendText("Host:" + host + "-" + port) ;
			mainSocket = new CustomSocket(host, port);	
			Load_Christmas() ;
			LoadXML() ;
			LoadEmotionLibrary(0) ;	
			LoadTyle() ;
			//LoadAuction() ;			
		}		
		function Load_Christmas() : void {
			christmas_Loader = new Loader();                     // create a new instance of the Loader class
			var url:URLRequest = new URLRequest("./flash/phaohoa.swf"); // in this case both SWFs are in the same folder
			christmas_Loader.load(url);                                     // load the SWF file
			//christmas_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
			christmas_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
			function errorHandler(errorEvent:Event):void {
				Load_Christmas() ;
			}
		}
		function LoadAuction(vFile : String):void {	
			//tf.appendText("==>StartLoadAuction") ;
			var tmpHide:MovieClip = MovieClip(new Hide());
			tmpHide.name = "Hide";
			tmpHide.x = 0 ;
			tmpHide.y = 0 ;
			tmpHide.alpha = 0 ;
			mainStage_mc.addChild(tmpHide) ;
			var loaderAuction:Loader = new Loader();
			loaderAuction.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
			loaderAuction.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
			loaderAuction.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
			var request:URLRequest = new URLRequest(vFile);
			var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
			loaderAuction.load(request, context);
			function onProgressHandler(event:ProgressEvent){
				var dataAmountLoaded:Number = (807834 + event.bytesLoaded) / (807834 + event.bytesTotal);
				mainStage_mc.progressbar.txtbar.text = (dataAmountLoaded*100 - 5).toFixed(0) + "%";
				mainStage_mc.progressbar.bar.scaleX = dataAmountLoaded - 0.05;
			}
			function onLoadComplete(e:Event):void {
				//tf.appendText("==>CompletedLoadAuction") ;			
				Popup_Daugia = Class(ApplicationDomain.currentDomain.getDefinition("Popup_Daugia"));
				Auction_Item = Class(ApplicationDomain.currentDomain.getDefinition("Auction_Item"));
				AuctionWin_Item = Class(ApplicationDomain.currentDomain.getDefinition("AuctionWin_Item"));
				Auction_ItemShow = Class(ApplicationDomain.currentDomain.getDefinition("Auction_ItemShow"));
				Popup_Xoso = Class(ApplicationDomain.currentDomain.getDefinition("Popup_Xoso"));
				Lottery_Item = Class(ApplicationDomain.currentDomain.getDefinition("Lottery_Item"));
				Lottery_ItemWin = Class(ApplicationDomain.currentDomain.getDefinition("Lottery_ItemWin"));
				Popup_Baimayman = Class(ApplicationDomain.currentDomain.getDefinition("Popup_Baimayman"));
				LuckyCard_Item = Class(ApplicationDomain.currentDomain.getDefinition("LuckyCard_Item"));
				LuckyCard = Class(ApplicationDomain.currentDomain.getDefinition("LuckyCard"));
				Lucky_Mau = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Mau"));
				Lucky_Doi = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Doi"));
				Lucky_Thu = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Thu"));
				Lucky_Xam = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Xam"));
				Lucky_Sanh = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Sanh"));
				Lucky_Thung = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Thung"));
				Lucky_Tuquy = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Tuquy"));
				Lucky_Culu = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Culu"));
				Lucky_Thungphasanh = Class(ApplicationDomain.currentDomain.getDefinition("Lucky_Thungphasanh"));	
				
				Popup_SpecialAlert = Class(ApplicationDomain.currentDomain.getDefinition("Popup_SpecialAlert"));	
				Popup_ConvertGold = Class(ApplicationDomain.currentDomain.getDefinition("Popup_ConvertGold"));
				
				var mcRemove : MovieClip = MovieClip(mainStage_mc.getChildByName("Hide")) ;
				if (mcRemove != null)
					mainStage_mc.removeChild(mcRemove) ;
			}
			function errorHandler(mProgress:IOErrorEvent)
			{
				LoadAuction(vFile) ;
			}
		}
		public static function LoadTyle() : void {
			var request:URLRequest = new URLRequest(urlTyle);
			request.method = URLRequestMethod.POST;
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onComplete);
			loader.dataFormat = URLLoaderDataFormat.TEXT;
			loader.load(request);
			function onComplete (event:Event):void {
				LQAGFunction.LQReceive(event.target.data) ;
			}
		}
		public static function LoadXML() : void {			
			var myLoader:URLLoader = new URLLoader();
			myLoader.load(new URLRequest(preURLXML + "InputCT.xml"));
			myLoader.addEventListener(Event.COMPLETE, processXML);
			function processXML(e:Event):void {
				myXML = new XML(e.target.data);
				if (mainStage_mc.currentFrame == 3) TopFunction.DisplayHotNew() ;
				LoadTopDG() ;
			}
		}
		
		public static function LoadTopDG() : void {
			var request:URLRequest = new URLRequest(urlTopDG);
			request.method = URLRequestMethod.POST;
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onComplete);
			loader.dataFormat = URLLoaderDataFormat.TEXT;
			loader.load(request);
			function onComplete (event:Event):void {
				TopFunction.TopDG(event.target.data) ;
				LoadTopCT_Trongngay() ;				
			}
		}
		public static function LoadTopCT_Trongngay() : void {
			var request:URLRequest = new URLRequest(urlTopCT_Trongngay);
			request.method = URLRequestMethod.POST;
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onComplete);
			loader.dataFormat = URLLoaderDataFormat.TEXT;
			loader.load(request);
			function onComplete (event:Event):void {
				TopFunction.TopCT_Trongngay(event.target.data) ;
				LoadTopCT_Homtruoc() ;
				//tf.appendText("CTTrongngay:" + event.target.data);
			}
		}
		public static function LoadTopCT_Homtruoc() : void {
			var request:URLRequest = new URLRequest(urlTopCT_Homtruoc);
			request.method = URLRequestMethod.POST;
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onComplete);
			loader.dataFormat = URLLoaderDataFormat.TEXT;
			loader.load(request);
			function onComplete (event:Event):void {
				TopFunction.TopCT_Homtruoc(event.target.data) ;
				LoadTopCT_Tuan() ;
				//tf.appendText("CTHomtruoc:" + event.target.data);
			}
		}
		public static function LoadTopCT_Tuan() : void {
			var request:URLRequest = new URLRequest(urlTopCT_Tuan);
			request.method = URLRequestMethod.POST;
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onComplete);
			loader.dataFormat = URLLoaderDataFormat.TEXT;
			loader.load(request);
			function onComplete (event:Event):void {
				TopFunction.TopCT_Tuan(event.target.data) ;
				LoadTopCT_Thang() ;
				//tf.appendText("CTTuan:" + event.target.data);
			}
		}
		public static function LoadTopCT_Thang() : void {
			var request:URLRequest = new URLRequest(urlTopCT_Thang);
			request.method = URLRequestMethod.POST;
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onComplete);
			loader.dataFormat = URLLoaderDataFormat.TEXT;
			loader.load(request);
			function onComplete (event:Event):void {
				TopFunction.TopCT_Thang(event.target.data) ;
				//tf.appendText("CTThang:" + event.target.data);
			}
		}
		public static function LoadEmotionLibrary(csE : int) : void {
			var imageLoader:Loader = new Loader();
			var image:URLRequest = new URLRequest(preURLEmotion + ArrNameEmotions[csE]) ;	
			imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoader);				
			imageLoader.name = "Emotion" ;
			imageLoader.load(image);		
			var mcAdd : MovieClip = MovieClip(new Emotion_Khung()) ;
			function onLoader(evt:Event)
			{				
				imageLoader.x = 0 ;
				imageLoader.y = 0 ;
				mcAdd.addChild(imageLoader) ;
				ArrEmotion.push(mcAdd) ;
				if (csE < 8) {					
					LoadEmotionLibrary(csE + 1) ;
				}
			}	
		}
		
		public static function mouseMove(evt :MouseEvent) {
			if (mainStage_mc.currentFrame != 5) return ;
			if (isView) return ;
			if (mcMove != null) {
				mcMove.x = mainStage_mc.mouseX - xMove - 6;
				mcMove.y = mainStage_mc.mouseY - yMove - 1; // - 6;
			}		
		}
		/******************************** Control Sound **************************/
		public static function PlaySoundKick(event : Event) {
			kickSound.play() ;
		}
		public static function SoundKick() {
			if (Cocaro.isSound) {
				try 
				{
					if (kickSound == null) {
						kickSound = new Sound(new URLRequest(preURLSound + "Kick.mp3"));
						kickSound.addEventListener(Event.COMPLETE, PlaySoundKick) ;
					} else {
						kickSound.play()
					}
				} catch (e:Error) { }
			}
		}
		public static function PlaySoundFinished(event : Event) {
			finishedSound.play() ;
		}
		public static function SoundFinish() {
			if (Cocaro.isSound) {
				try 
				{
					if (finishedSound == null) {
						finishedSound = new Sound(new URLRequest(preURLSound + "Finished.mp3"));
						finishedSound.addEventListener(Event.COMPLETE, PlaySoundFinished) ;
					} else {
						finishedSound.play()
					}
				} catch (e :Error) { }
			}
		}
		public static function PlaySoundMessage(event : Event) {
			msgSound.play() ;
		}
		public static function SoundMessage() {
			if (Cocaro.isSound) {
				try
				{
					if (msgSound == null) {
						msgSound = new Sound(new URLRequest(preURLSound + "Message.mp3"));
						msgSound.addEventListener(Event.COMPLETE, PlaySoundMessage) ;
					} else {
						msgSound.play()
					}
				} catch (e:Error) { }
			}	
		}
		/******************************************************************************************************/
		public static function Feed() : void {
			ExternalInterface.call("pushfeed", Cocaro.user.UserId);
		}
		public static function PromotionAlert(str : String) {
			var objArr : Array = JSON.decode(str) as Array ;
			for (var i:int = 0; i < objArr.length; i++) 
			{
				if (objArr[i].AG == 0) {
					var tmpTB:MovieClip = MovieClip(new Popup_Alert_GetProfile());
					tmpTB.name = "Alert";
					tmpTB.x = 240;
					tmpTB.y = 220;
					tmpTB.Content_txt.text = objArr[i].Message ;
					tmpTB.btnXacnhan.addEventListener(MouseEvent.CLICK, btnXacnhan1_PR_click);
					tmpTB.Close_btn.addEventListener(MouseEvent.CLICK, CloseProfile_PR_click);
				} else {
					var tmpTB:MovieClip = MovieClip(new Popup_Alert());
					tmpTB.name = "Alert";
					tmpTB.x = 240;
					tmpTB.y = 220;
					tmpTB.Content_txt.text = objArr[i].Message ;
					tmpTB.Close_btn.addEventListener(MouseEvent.CLICK, Close_PR_click);
				}
				mainStage_mc.addChild(tmpTB);
			}
		}
		public static function CloseProfile_PR_click(evt:MouseEvent) {//Xu ly Kick Huy bo tren popup vao ban
			Cocaro.SoundKick() ;
			Clean_Message() ;
		}
		public static function btnXacnhan1_PR_click(evt:MouseEvent) {
			Cocaro.SoundKick() ;
			Clean_Message() ;
			var obj1:Object = new Object();
			obj1.Username = currPlayer.PlayerName;
			ExternalInterface.call("UpdatePromotion",JSON.encode(obj1));
			var url:String = "http://game.athena.vn/gamerinfo/gamerinfodetails.aspx?session_id=" + user.SessionId + "&sign_user=" + user.UserId + "&username=" + user.Username;
            var request:URLRequest = new URLRequest(url);
			navigateToURL(request, "");
		}
		public static function Close_PR_click(evt:MouseEvent) {
			Cocaro.SoundKick() ;
			Clean_Message() ;
			var obj1:Object = new Object();
			obj1.Username = currPlayer.PlayerName;
			ExternalInterface.call("UpdatePromotion",JSON.encode(obj1));			
		}
		public static function Clean_Message() : void {
			var tmp :MovieClip = MovieClip(mainStage_mc.getChildByName("Alert")) ;
			while (tmp != null) {
				mainStage_mc.removeChild(tmp) ;
				tmp = MovieClip(mainStage_mc.getChildByName("Alert")) ;
			}	
			var tmpHide:MovieClip = MovieClip(mainStage_mc.getChildByName("Hide"));
			while (tmpHide != null) {
				mainStage_mc.removeChild(tmpHide) ;
				tmpHide = MovieClip(mainStage_mc.getChildByName("Hide"));
			}
		}
		
		public static function NapAG_Popup_Click(evt : MouseEvent) {
			var url:String = "http://tienlenmn.athena.vn/tienlenmn/ZingCredit.aspx?session_id=" + user.SessionId + "&sign_user=" + user.UserId + "&username=" + user.Username;
            var request:URLRequest = new URLRequest(url);
			navigateToURL(request, "");
		}
		
		public static function Choitiep_Popup_Click(evt : MouseEvent) {
			var tmp :MovieClip = MovieClip(mainStage_mc.getChildByName("TangAG")) ;
			while (tmp != null) {
				mainStage_mc.removeChild(tmp) ;
				tmp = MovieClip(mainStage_mc.getChildByName("TangAG")) ;
			}	
			BasicFunction.RemoveHideLoading() ;
		}
		
		public static function processDisconnectServer() : void {
			while (mainStage_mc.numChildren > 0)
				mainStage_mc.removeChildAt(0) ;
			mainStage_mc.gotoAndStop(2) ;
			BasicFunction.ShowAlert("Bạn bị đứt kết nối với máy chủ") ;
		}
		
	}	
} 
